/*
* INSANE - Interactive Structural Analysis Environment
*
* Copyright (C) 2003-2005
* Universidade Federal de Minas Gerais
* Escola de Engenharia
* Departamento de Engenharia de Estruturas
* 
* Author's email :    insane@dees.ufmg.br
* Author's website :  http://www.dees.ufmg.br/insane
* 
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
package br.ufmg.dees.insane.ui.rich.learn.learn_view.displacements_view.command;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import br.ufmg.dees.insane.ui.rich.learn.learn_view.HtmlDA;
import br.ufmg.dees.insane.ui.rich.learn.learn_view.HtmlFormatter;
import br.ufmg.dees.insane.ui.rich.learn.learn_view.LearnInterface;
import br.ufmg.dees.insane.ui.rich.learn.learn_view.dialog.EnhancedDialog;

/**
 * Class representing Help0Dialog
 * @author roque
 * @since Aug 10, 2005
 */
public class Help1Dialog extends EnhancedDialog {

	private static final long serialVersionUID = 1L;
	private JButton close;
	
//*****************************************************************************
	
	/**Constructor*/
	public Help1Dialog(LearnInterface parent) {
		super(parent,"INSANE Help",true);
		
		JPanel content = new JPanel(new BorderLayout());
		content.setSize(300,300);//.setBorder(new EmptyBorder(12,12,12,12));
		setContentPane(content);
		
		HtmlDisplacementsFormatter hf = new HtmlDisplacementsFormatter();
		String text = HtmlFormatter.format(hf.format());
        
		HtmlDA html = new HtmlDA(parent);
	  
	    
		html.setText(text);
       
		content.add(BorderLayout.CENTER, html);
		
		
		JPanel buttonPanel = new JPanel();
		buttonPanel.setLayout(new BoxLayout(buttonPanel,BoxLayout.X_AXIS));
		buttonPanel.setBorder(new EmptyBorder(12,0,0,0));
		
		buttonPanel.add(Box.createGlue());
		close = new JButton("Close");
		close.addActionListener(new ActionHandler());
		getRootPane().setDefaultButton(close);
		buttonPanel.add(close);
		buttonPanel.add(Box.createGlue());
		content.add(BorderLayout.SOUTH,buttonPanel);
		
		pack();
		setResizable(false);
		setLocationRelativeTo(parent);
		
		setVisible(true);
	}
	
	/**ok() method*/
	public void ok() {
		dispose();
	}
	
	
	/**cancel() method*/
	public void cancel() {
		dispose();
	}
	
	
	//ActionHandler class
	class ActionHandler implements ActionListener {
		public void actionPerformed(ActionEvent evt) {
			dispose();
		}
	}
}
